﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/Master/FrameMain.Master" ValidateRequest="false"
    AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Cms.Admin.Article.Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        table
        {
            width: 100%;
        }
        .style1
        {
            width: 90px;
            text-align: right;
            padding-right: 5px;
            height: 30px;
             white-space:nowrap;
        }
        .style2
        {
        }
    </style>

    <script type="text/javascript" src="../../Common/Js/attach.js"></script>
    <script type="text/javascript" src="../../Common/fckeditor/fckeditor.js"></script>
   
    <script type="text/javascript">
        function InsertImage(url,fileName)
        {
            var oEditor = FCKeditorAPI.GetInstance("Content");
            oEditor.InsertHtml("<img src='" + url + "' alt='" + fileName + "'></img");
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="toolbar">
        <ul>
            <li><a id="lnkSave" runat="server" href="javascript:;"><span><b style="background-image: url(../../common/images/common/save.gif);
                width: 35px;">&nbsp;</b><asp:Literal ID="Literal7" runat="server" Text="保存"></asp:Literal></span></a></li>
            <li><a id="lnkBack" runat="server" href="javascript:history.back();"><span><b style="background-image: url(../../common/images/common/back.gif);">
                &nbsp;</b><asp:Literal ID="Literal9" runat="server" Text="返回"></asp:Literal></span></a></li>
        </ul>
    </div>
    <asp:Panel ID="pnlMain" runat="server" Style="overflow-x: hidden; width: 100%;">
        <div style="padding: 0px 30px 0px 10px;">
            <table cellpadding="0" cellspacing="0">
                <tr class="dashed">
                    <td class="style1">
                        标题：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="Name" runat="server" CssClass="txt" Width="400px" MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                            ControlToValidate="Name" ErrorMessage="请输入标题"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        栏目：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="txtMenuName" runat="server" CssClass="txt" Width="400px"></asp:TextBox><asp:HiddenField
                            ID="hidMenuIDs" runat="server" /> 
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                        ErrorMessage="请选择栏目" ControlToValidate="txtMenuName" Display="Dynamic"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        来源：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="Source" runat="server" CssClass="txt" Width="400px"></asp:TextBox>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        标题图片：
                    </td>
                    <td class="style2">
                        <asp:FileUpload ID="fileTitlePicture" runat="server" CssClass="txt" />
                        <a id="lnkTitlePicture" runat="server" target="_blank"><asp:Image ID="imgTitlePicture" runat="server" Visible= "false" Height="25px" ImageAlign="AbsMiddle" /></a>
                        <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/common/images/Common/delAttach.gif"
                                    ImageAlign="AbsMiddle"   Visible=false
                            OnClientClick="return confirm('确认删除标题图片?')" onclick="btnDelete_Click" />
                         <asp:CheckBox ID="IsRecommend" runat="server" Text="推荐" />&nbsp;<asp:CheckBox ID="IsDisplay"
                            runat="server" Checked="true" Text="显示" />
                    </td>
                </tr>
                
                <tr class="dashed">
                    <td class="style1">
                        内容：
                    </td>
                    <td class="style2">

                        <script type="text/javascript">
                <!--
                            // Automatically calculates the editor base path based on the _samples directory.
                            // This is usefull only for these samples. A real application should use something like this:
                            // oFCKeditor.BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
                            var sBasePath = "/common/fckeditor/";

                            var oFCKeditor = new FCKeditor('Content');
                            oFCKeditor.BasePath = sBasePath;
                            oFCKeditor.Height = 400;
                            oFCKeditor.Width = 700;
                            oFCKeditor.ToolbarSet = "SiteAdmin";
                            oFCKeditor.Value = '<%=Content %>';
                            oFCKeditor.Create();
                //-->
                        </script>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        内容图片：
                    </td>
                    <td class="style2">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td style="width: 80px">
                                    <script type="text/javascript">
                                        ImageUpload.ImageAdded = function (msg)
                                        {
                                            var oEditor = FCKeditorAPI.GetInstance("Content");
                                            oEditor.InsertHtml("[img]" + msg + "[/img]");
                                        }
                                        new ImageUpload("fileList", "pic");                                      
                                    </script>
                                </td>
                                <td id="fileList" style="word-break: break-all; padding-left: 5px;">
                                   
                                </td>
                            </tr>
                            
                        </table>
                    </td>
                </tr>
                <tr class="dashed" id="trImages" runat="server">
                    <td class="style1">
                    </td>
                    <td>
                        <asp:Repeater ID="rptPicture" runat="server" 
                            onitemcommand="rptPicture_ItemCommand">
                            <ItemTemplate>
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/common/images/Common/attach.gif" />&nbsp;<asp:HyperLink
                                    ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("BigImageAbsPath") %>' Text='<%# Eval("Name") %>'
                                    Target="_blank"></asp:HyperLink>
                                <a href="javascript:InsertImage('<%# Eval("BigImageAbsPath") %>','<%# Eval("Name") %>');">[插入]</a>
                                <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/common/images/Common/delAttach.gif"
                                    ImageAlign="AbsMiddle" CommandName="Delete" CommandArgument='<%#Eval("ID") %>' OnClientClick="return confirm('确认删除图片?')" />;&nbsp;
                            </ItemTemplate>
                        </asp:Repeater>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        摘要：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="Summary" runat="server" CssClass="txt" Height="40px" MaxLength="1000"
                            TextMode="MultiLine" Width="450px"></asp:TextBox>
                    </td>
                </tr>
                <tr class="dashed">
                    <td class="style1">
                        关键字：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="KeyWords" runat="server" CssClass="txt" Width="450px"></asp:TextBox>
                    </td>
                </tr>               
                <tr class="dashed">
                    <td class="style1">
                        附件：
                    </td>
                    <td class="style2">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td style="width: 80px">
                                    <script type="text/javascript">
                                        new Attach("attachList","attach");
                                    </script>
                                </td>
                                <td id="attachList" style="word-break: break-all; padding-left: 5px;">
                                    
                                </td>
                            </tr>
                           
                        </table>
                    </td>
                </tr>
                <tr class="dashed">
                    <td>
                    </td>
                    <td>
                        <asp:Repeater ID="rptAttach" runat="server" OnItemCommand="rptAttach_ItemCommand">
                            <ItemTemplate>
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/common/images/Common/attach.gif" />&nbsp;<asp:HyperLink
                                    ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("DownloadUrl") %>' Text='<%# Eval("Name") %>'></asp:HyperLink>
                                <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/common/images/Common/delAttach.gif"
                                    ImageAlign="AbsMiddle" CommandName="Delete"  CommandArgument='<%#Eval("ID") %>'  OnClientClick="return confirm('确认删除附件?')" />;&nbsp;
                            </ItemTemplate>
                        </asp:Repeater>
                    </td>
                </tr>
            </table>
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td style="height: 2px;">
                        <img src="../../Common/Images/Common/keyline.gif" alt="" style="height: 2px; width: 100%" />
                    </td>
                </tr>
            </table>
        </div>
        <div style="text-align: left; padding-left: 100px; margin-top: 5px;" id="buttons">
            <asp:Button ID="btnSave" runat="server" Text="保存" Width="60px" OnClick="btnSave_Click" />&nbsp;&nbsp;
            <input id="Button1" type="button" value="返回" style="width: 60px;" onclick="history.back()" />
        </div>
        <div>
            &nbsp;</div>
    </asp:Panel>
    <script type="text/javascript">

        var form = document.forms[0];

        function form_submit()
        {
            
            if (Page_IsValid)//判断验证控件是否全部通过验证
            {
                window.setTimeout(function()
                {

                    var btnSave = document.getElementById("<%=btnSave.ClientID %>");
                    btnSave.value = "正在提交数据...";
                    btnSave.style.width = "200px";
                    //btnSave.disabled = "disabled";
                    btnSave.onclick = function()
                    {
                        alert("正在提交数据，请勿重复提交！");
                        return false;
                    };
                }, 1);
            }
        }

        if (form.attachEvent)
        {
            form.attachEvent("onsubmit", form_submit);
        }
        else if (form.addEventListener)
        {
            form.addEventListener("submit", form_submit, false);
        }
        
</script>
</asp:Content>
